package com.tianyadu.security.validator;

import com.tianyadu.security.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @FileName: MyConstraintValidator
 * @Description: 自定义注解业务逻辑
 * @author: xueyj
 * @create: 2018-12-05 06:29
 */
@Slf4j
public class MyConstraintValidator implements ConstraintValidator<MyConstraint, Object> {

    @Autowired
    private UserService userService;

    @Override
    public void initialize(MyConstraint constraintAnnotation) {
        System.out.println("my validator init");
    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext context) {
        //List<UserInfo> all = userService.findAll();
        log.info("自定义注解业务逻辑查询全部用户信息，UserInfoList = 【{}】");
        return true;
    }
}